<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
var minimumCardPickup = function(cards) {
    const map = new Map()
    let ans = Infinity
    for (let i = 0; i < cards.length; i ++) {
        const c = cards[i]
        if (map.has(c)) {
            ans = Math.min(ans, i - map.get(c) + 1)
        }
        map.set(c, i)
    }
    return ans === Infinity ? -1 : ans
};
  </script>
</body>
</html>